﻿<!--/* 
* Copyright (c) 2010, The University of Texas at Austin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, 
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, 
* this list of conditions and the following disclaimer in the documentation and/or other materials 
* provided with the distribution.
*
* Neither the name of The University of Texas at Austin nor the names of its contributors may be 
* used to endorse or promote products derived from this software without specific prior written 
* permission.
* 
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/-->
 <UserControl x:Class="Bio.Views.Structure.Editor.Views.SecondaryStructureEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:SharedResources="clr-namespace:Bio.SharedResources;assembly=Bio.SharedResources"
             xmlns:Rendering="clr-namespace:Bio.Views.Structure.Editor.Internal.Rendering"
             xmlns:Visuals="clr-namespace:Bio.Views.Structure.Editor.Internal.Rendering.Visuals"
             xmlns:Views="clr-namespace:Bio.Views.Structure.Editor.Views"
             xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:ExpressionSamples="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity"
             xmlns:julmar="http://www.julmar.com/wpfhelpers"
             xmlns:Resources="clr-namespace:Bio.Views.Structure.Editor.Resources"
             xmlns:SECommands="clr-namespace:Bio.Views.Structure.Editor.Internal.Commands"
             xmlns:SDActions="clr-namespace:Bio.Views.Structure.Editor.Internal.Actions"
             x:Name="secondaryStructureEditor"
             UseLayoutRounding="True"
             SnapsToDevicePixels="True">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <Resources:DataTemplates />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>       
    </UserControl.Resources>
    <UserControl.InputBindings>
        <KeyBinding Key="Z" Modifiers="Control" Command="{Binding Path=UndoLastEditCommand}" />
        <KeyBinding Key="S" Modifiers="Control" Command="{Binding Path=DrawingSaveAsCommand}" />
        <KeyBinding Key="J" Modifiers="Control" Command="{Binding Path=TranslateStructureElementLeftCommand}" />
        <KeyBinding Key="L" Modifiers="Control" Command="{Binding Path=TranslateStructureElementRightCommand}" />
        <KeyBinding Key="M" Modifiers="Control" Command="{Binding Path=TranslateStructureElementDownCommand}" />
        <KeyBinding Key="I" Modifiers="Control" Command="{Binding Path=TranslateStructureElementUpCommand}" />
        <KeyBinding Key="J" Modifiers="Alt" Command="{Binding Path=RotateStructureElementLeftCommand}" />
        <KeyBinding Key="L" Modifiers="Alt" Command="{Binding Path=RotateStructureElementRightCommand}" />
        <KeyBinding Key="OemPlus" Command="{Binding Path=RotateStructureElementLeftIncrementCommand}" />
        <KeyBinding Key="OemMinus" Command="{Binding Path=RotateStructureElementRightIncrementCommand}" />
    </UserControl.InputBindings>
    <Grid>
        <Grid.Resources>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="325"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <DockPanel Grid.Column="0">
            <StatusBar DockPanel.Dock="Bottom">
                <StatusBarItem>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="2,3,2,3" Text="Zoom:"></TextBlock>
                        <ComboBox x:Name="zoomSelector" 
                                  SelectionChanged="OnSecondaryStructureStructureDrawingZoomSelectionChanged"
                                  DisplayMemberPath="Label">
                        </ComboBox>
                    </StackPanel>
                </StatusBarItem>
                <StatusBarItem>
                    <StackPanel Orientation="Horizontal"
                                Margin="20,0,0,0">
                        <TextBlock Margin="2,3,2,3" Text="Selection Mode: "></TextBlock>
                        <ComboBox x:Name="selectionModeSelector"
                                  SelectedValuePath="Mode"
                                  SelectionChanged="OnSecondaryStructureEditorSelectionModeSelectionChanged"
                                  DisplayMemberPath="Label"></ComboBox>
                    </StackPanel>
                </StatusBarItem>
            </StatusBar>

            <StackPanel DockPanel.Dock="Bottom">
                <TextBlock Text="{Binding ElementName=secondaryStructureDrawing, Path=CurrentStructureDrawingTool.Message, StringFormat=Drawing\ Tool: \{0\}}"
                           Foreground="{StaticResource TextBrush}"
                           TextWrapping="Wrap">
                </TextBlock>
                <TextBlock Text="{Binding ElementName=secondaryStructureDrawing, Path=SelectedStructureElementVisual.ContextMessage, StringFormat=Selection\ Context: \{0\}}"
                           Foreground="{StaticResource TextBrush}"
                           TextWrapping="Wrap">
                </TextBlock>
            </StackPanel>

            <Popup x:Name="structureModelEditingToolMessageBox"
	               IsOpen="False"
	               Placement="MousePoint"
	               VerticalOffset="10"
	               HorizontalOffset="10">
                <TextBlock Text="{Binding ElementName=secondaryStructureDrawing, Path=CurrentStructureModelEditingTool.Message}"
	                       TextWrapping="Wrap"
	                       Width="200"
	                       Background="LightBlue"></TextBlock>
            </Popup>
 
            <ScrollViewer Background="{x:Null}"
                          HorizontalScrollBarVisibility="Auto"
                          VerticalScrollBarVisibility="Auto"
                          x:Name="drawingScroller">
                <Grid Background="LightGray"
                      x:Name="drawingPanel">
                    <Rendering:SecondaryStructureDrawing StructureData="{Binding}"
                                                         SelectedStructureElementVisualID="{Binding RelativeSource={RelativeSource AncestorType={x:Type Views:SecondaryStructureEditor}}, Path=SelectedStructureElementID, Mode=TwoWay}"
                                                         NucleotideDefaultRenderingOptionSets="{Binding Path=RuntimeNucleotideVisualRenderingOptions}"
                                                         BasePairDefaultRenderingOptionSets="{Binding Path=RuntimeBasePairVisualRenderingOptions}"
                                                         HorizontalAlignment="Center"
                                                         VerticalAlignment="Center"
                                                         NucleotideFontFamily="{Binding Path=NucleotideFontFamily, Mode=TwoWay}"
                                                         NucleotideFontStyle="{Binding Path=NucleotideFontStyle, Mode=TwoWay}"
                                                         NucleotideFontWeight="{Binding Path=NucleotideFontWeight, Mode=TwoWay}"
                                                         NucleotideFontSize="{Binding Path=NucleotideFontSize, Mode=TwoWay}"
                                                         NucleotideFill="{Binding Path=NucleotideFill, Mode=TwoWay}"
                                                         NucleotideRenderingStyle="{Binding Path=NucleotideRenderingStyle, Mode=TwoWay}"
                                                         NucleotideCircleDiameter="{Binding Path=NucleotideCircleDiameter, Mode=TwoWay}"
                                                         NucleotideCircleEdgeThickness="{Binding Path=NucleotideCircleEdgeThickness, Mode=TwoWay}"
                                                         NucleotideCircleFill="{Binding Path=NucleotideCircleFill, Mode=TwoWay}"
                                                         NucleotideCircleIsFilled="{Binding Path=NucleotideCircleIsFilled, Mode=TwoWay}"
                                                         NucleotideCircleStroke="{Binding Path=NucleotideCircleStroke, Mode=TwoWay}"
                                                         BasePairConnectorFill="{Binding Path=BasePairConnectorFill, Mode=TwoWay}"
                                                         BasePairConnectorRenderingStyle="{Binding Path=BasePairConnectorRenderingStyle, Mode=TwoWay}"
                                                         BasePairConnectorIsFilled="{Binding Path=BasePairConnectorIsFilled, Mode=TwoWay}"
                                                         BasePairConnectorIsVisible="{Binding Path=BasePairConnectorIsVisible, Mode=TwoWay}"
                                                         BasePairConnectorSize="{Binding Path=BasePairConnectorSize, Mode=TwoWay}"
                                                         BasePairConnectorStroke="{Binding Path=BasePairConnectorStroke, Mode=TwoWay}"
                                                         BasePairConnectorStrokeThickness="{Binding Path=BasePairConnectorStrokeThickness, Mode=TwoWay}"
                                                         DrawingDirty="{Binding Path=CurrentDrawingDirtyState, Mode=OneWayToSource}"
                                                         x:Name="secondaryStructureDrawing">
                        <Rendering:SecondaryStructureDrawing.LayoutTransform>
                            <ScaleTransform x:Name="ssScaler"
                                            ScaleX="{Binding ElementName=secondaryStructureEditor, Path=ZoomFactor}" 
                                            ScaleY="{Binding ElementName=secondaryStructureEditor, Path=ZoomFactor}">
                            </ScaleTransform>
                        </Rendering:SecondaryStructureDrawing.LayoutTransform>
                        <Interactivity:Interaction.Triggers>
                            <ExpressionSamples:DataEventTrigger EventName="SynchronizeStructureModelState" Source="{Binding}">
                                <SDActions:UpdateStructureModelAction></SDActions:UpdateStructureModelAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="UndoLastEdit" Source="{Binding}">
                                <SDActions:UndoLastStructureModelEditAction></SDActions:UndoLastStructureModelEditAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="DeleteSelectedBasePair" Source="{Binding}">
                                <SDActions:DeleteSelectedBasePairEditAction></SDActions:DeleteSelectedBasePairEditAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="DeleteSelectedHelix" Source="{Binding}">
                                <SDActions:DeleteSelectedHelixAction></SDActions:DeleteSelectedHelixAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="DeleteBasePairsFromRange" Source="{Binding}">
                                <SDActions:DeleteBasePairsFromRangeAction></SDActions:DeleteBasePairsFromRangeAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="SnapSelectedHelixToOpeningBasePair" Source="{Binding}">
                                <SDActions:SnapSelectedHelixToOpeningBasePairAction></SDActions:SnapSelectedHelixToOpeningBasePairAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="SnapSelectedHelixToClosingBasePair" Source="{Binding}">
                                <SDActions:SnapSelectedHelixToClosingBasePairAction></SDActions:SnapSelectedHelixToClosingBasePairAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="EditStructureElementProperties" Source="{Binding}">
                                <SDActions:EditStructureElementPropertiesAction></SDActions:EditStructureElementPropertiesAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="TranslateSelectedStructureElement" Source="{Binding}">
                                <SDActions:TranslateSelectedStructureElementAction></SDActions:TranslateSelectedStructureElementAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="RotateSelectedStructureElement" Source="{Binding}">
                                <SDActions:RotateSelectedStructureElementAction></SDActions:RotateSelectedStructureElementAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="ResizeStructureElement" Source="{Binding}">
                                <SDActions:ResizeStructureElementAction></SDActions:ResizeStructureElementAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="CreateStructureElement" Source="{Binding}">
                                <SDActions:CreateStructureElementAction></SDActions:CreateStructureElementAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="StructureModelDataChanged" Source="{Binding}">
                                <SDActions:ReloadStructureDrawingAction></SDActions:ReloadStructureDrawingAction>
                            </ExpressionSamples:DataEventTrigger>
                            <ExpressionSamples:DataEventTrigger EventName="SelectStructureElementContainingNucleotide" Source="{Binding}">
                                <SDActions:SelectStructureElementContainingNucleotideAction></SDActions:SelectStructureElementContainingNucleotideAction>
                            </ExpressionSamples:DataEventTrigger>
                        </Interactivity:Interaction.Triggers>
                        <Rendering:SecondaryStructureDrawing.ContextMenu>
                            <ContextMenu ItemContainerStyle="{StaticResource ContextMenuItemStyle}" ItemsSource="{Binding Path=SelectedElementContextMenu, UpdateSourceTrigger=PropertyChanged}"></ContextMenu>
                        </Rendering:SecondaryStructureDrawing.ContextMenu>
                    </Rendering:SecondaryStructureDrawing>
                    <Grid.ContextMenu>
                        <ContextMenu ItemContainerStyle="{StaticResource ContextMenuItemStyle}" ItemsSource="{Binding Path=SelectedElementContextMenu, UpdateSourceTrigger=PropertyChanged}"></ContextMenu>
                    </Grid.ContextMenu>
                </Grid>
            </ScrollViewer>

        </DockPanel>
        
        <ScrollViewer Grid.Column="1">
            <StackPanel Margin="2">
                <StackPanel.Resources>
                    <DataTemplate x:Key="toolButtonTemplate">
                        <StackPanel>
                            <ToggleButton IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"
                                          IsEnabled="{Binding Path=IsEnabled}"
                                          Content="{Binding Path=Icon}"
                                          Padding="8,6">
                                <ToggleButton.ToolTip>
                                    <TextBlock Text="{Binding Path=ToolTip}"></TextBlock>
                                </ToggleButton.ToolTip>
                            </ToggleButton>
                        </StackPanel>
                    </DataTemplate>
                </StackPanel.Resources>
                <Expander Header="Structure Drawing Tools"
                          IsExpanded="True">
                    <ListBox ItemsSource="{Binding ElementName=secondaryStructureDrawing, Path=StructureDrawingTools}"
                             SelectedItem="{Binding ElementName=secondaryStructureDrawing, Path=CurrentStructureDrawingTool}"
                             ItemTemplate="{StaticResource toolButtonTemplate}">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel></WrapPanel>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </Expander>
                
                <Expander Header="Structure Model Editing Tools"
                          IsExpanded="True">
                    <ListBox ItemsSource="{Binding ElementName=secondaryStructureDrawing, Path=StructureModelEditingTools}"
                             SelectedItem="{Binding ElementName=secondaryStructureDrawing, Path=CurrentStructureModelEditingTool}"
                             ItemTemplate="{StaticResource toolButtonTemplate}">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel></WrapPanel>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </Expander>
                
                <Expander Header="Loaded Structure Model Set"
                          Visibility="{Binding Path=IsStructureModelSetLinkable, Converter={julmar:BooleanToVisibilityConverter TrueTreatment=Visible, FalseTreatment=Collapsed}}"
                          ExpandDirection="Down"
                          IsExpanded="True">
                    <Grid Margin="2">
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition Width="1"></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <Rectangle Grid.Column="1"
                                   Grid.RowSpan="4"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Stretch"
                                   Fill="White"></Rectangle>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="0"
                                   HorizontalAlignment="Left"
                                   Text="Entities Loaded"></TextBlock>
                        <TextBlock Grid.Column="2"
                                   Grid.Row="0"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Path=LoadedModelCount}"></TextBlock>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="1"
                                   HorizontalAlignment="Left"
                                   Text="In-Memory Entities"></TextBlock>
                        <TextBlock Grid.Column="2"
                                   Grid.Row="1"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Path=InMemoryModelCount}"></TextBlock>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="2"
                                   HorizontalAlignment="Left"
                                   Text="rCAD AlnID"></TextBlock>
                        <TextBlock Grid.Column="2"
                                   Grid.Row="2"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Path=RCADAlignmentId}"></TextBlock>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="3"
                                   HorizontalAlignment="Left"
                                   Text="Linked"></TextBlock>
                        <CheckBox Grid.Column="2"
                                  Grid.Row="3"
                                  HorizontalAlignment="Center"
                                  HorizontalContentAlignment="Center"
                                  IsEnabled="False"
                                  Margin="5,0,0,0"
                                  IsChecked="{Binding Path=IsStructureModelSetLinked, Mode=OneWay}"></CheckBox>
                    </Grid>
                </Expander>

                <Expander Header="Selected Structure Model"
                          Visibility="{Binding Path=IsStructureModelSetLinkable, Converter={julmar:BooleanToVisibilityConverter TrueTreatment=Visible, FalseTreatment=Collapsed}}"
                          ExpandDirection="Down"
                          IsExpanded="True">
                    <Grid Margin="2">
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition Width="1"></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <Rectangle Grid.Column="1"
                                   Grid.RowSpan="5"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Stretch"
                                   Fill="White"></Rectangle>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="0"
                                   Text="Scientific Name"
                                   HorizontalAlignment="Left"></TextBlock>
                        <TextBlock Grid.Column="2"
                                   Grid.Row="0"
                                   TextWrapping="Wrap"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Path=RCADScientificName}"></TextBlock>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="1"
                                   Text="rCAD SeqID"
                                   HorizontalAlignment="Left"></TextBlock>
                        <TextBlock Grid.Column="2"
                                   Grid.Row="1"
                                   HorizontalAlignment="Center"
                                   Text="{Binding Path=RCADSequenceId}"></TextBlock>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="2"
                                   Text="In-Memory Only"
                                   HorizontalAlignment="Left"></TextBlock>
                        <CheckBox Grid.Column="2"
                                  Grid.Row="2"
                                  IsEnabled="False"
                                  IsChecked="{Binding Path=CurrentStructure.InMemoryDataOnly}"
                                  Margin="5,0,0,0"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Center"></CheckBox>

                        <TextBlock Grid.Column="0"
                                   Grid.Row="3"
                                   Text="Linked"
                                   HorizontalAlignment="Left"></TextBlock>
                        <CheckBox Grid.Column="2"
                                  Grid.Row="3"
                                  IsEnabled="False"
                                  IsChecked="{Binding Path=IsCurrentStructureLinked, Mode=OneWay}"
                                  Margin="5,0,0,0"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Center"></CheckBox>
                    </Grid>
                </Expander>
                
                <Expander ExpandDirection="Down"
                          Header="Structure Model Properties"
                          IsExpanded="True">
                    <StackPanel>
                        <Grid Margin="2">
                            <Grid.RowDefinitions>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition Width="1"></ColumnDefinition>
                                <ColumnDefinition></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <Rectangle Grid.Column="1"
                                       Grid.RowSpan="4"
                                       HorizontalAlignment="Stretch"
                                       VerticalAlignment="Stretch"
                                       Fill="White"></Rectangle>

                            <TextBlock Text="Sequence Length"
                                       Grid.Column="0"
                                       Grid.Row="0"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Text="{Binding Path=CurrentStructure.Entity.Sequence.SequenceData.Count}"
                                       Grid.Column="2"
                                       Grid.Row="0"
                                       HorizontalAlignment="Center"></TextBlock>

                            <TextBlock Text="Visible Nucleotides"
                                       Grid.Column="0"
                                       Grid.Row="1"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Text="{Binding ElementName=secondaryStructureDrawing, Path=CurrentVisibleNucleotideCount}"
                                       Grid.Column="2"
                                       Grid.Row="1"
                                       HorizontalAlignment="Center"></TextBlock>

                            <TextBlock Text="Base Pairs"
                                       Grid.Column="0"
                                       Grid.Row="2"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Text="{Binding ElementName=secondaryStructureDrawing, Path=CurrentBasePairCount}"
                                       Grid.Column="2"
                                       Grid.Row="2"
                                       HorizontalAlignment="Center"></TextBlock>

                            <TextBlock Text="Helices"
                                       Grid.Column="0"
                                       Grid.Row="3"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Text="{Binding ElementName=secondaryStructureDrawing, Path=CurrentHelixCount}"
                                       Grid.Column="2"
                                       Grid.Row="3"
                                       HorizontalAlignment="Center"></TextBlock>

                            <Grid Grid.Row="4"
                                  Grid.ColumnSpan="3">
                                <TextBlock HorizontalAlignment="Left"
                                           Text="Dimensions"
                                           FontWeight="Bold"
                                           TextDecorations="Underline">
                                </TextBlock>
                            </Grid>

                            <Rectangle Grid.Column="1"
                                       Grid.Row="5"
                                       Grid.RowSpan="3"
                                       HorizontalAlignment="Stretch"
                                       VerticalAlignment="Stretch"
                                       Fill="White">
                            </Rectangle>

                            <TextBlock Text="Canvas"
                                       Grid.Column="0"
                                       Grid.Row="5"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Grid.Column="2"
                                       Grid.Row="5"
                                       HorizontalAlignment="Center">
	                                <TextBlock.Text>
	                                    <MultiBinding StringFormat="{}{0:f} x {1:f}">
	                                        <Binding ElementName="secondaryStructureDrawing" Path="CanvasWidth"></Binding>
	                                        <Binding ElementName="secondaryStructureDrawing" Path="CanvasHeight"></Binding>
	                                    </MultiBinding>
	                                </TextBlock.Text>
                            </TextBlock>

                            <TextBlock Text="Drawing"
                                       Grid.Column="0"
                                       Grid.Row="6"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Grid.Column="2"
                                       Grid.Row="6"
                                       HorizontalAlignment="Center">
	                                <TextBlock.Text>
	                                    <MultiBinding StringFormat="{}{0:f} x {1:f}">
	                                        <Binding ElementName="secondaryStructureDrawing" Path="DrawingWidth"></Binding>
	                                        <Binding ElementName="secondaryStructureDrawing" Path="DrawingHeight"></Binding>
	                                    </MultiBinding>
	                                </TextBlock.Text>
                            </TextBlock>

                            <TextBlock Text="Background"
                                       Grid.Column="0"
                                       Grid.Row="7"
                                       HorizontalAlignment="Left"></TextBlock>
                            <Rectangle HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Width="20"
                                       Height="10"
                                       Grid.Column="2"
                                       Grid.Row="7"
                                       Fill="{Binding ElementName=secondaryStructureDrawing, Path=DrawingBackground}">
                            </Rectangle>

                            <Grid Grid.Row="8"
                                  Grid.ColumnSpan="3">
                                <TextBlock HorizontalAlignment="Left"
                                           Text="Viewport Properties"
                                           FontWeight="Bold"
                                           TextDecorations="Underline">
                                </TextBlock>
                            </Grid>

                            <Rectangle Grid.Column="1"
                                       Grid.Row="9"
                                       Grid.RowSpan="2"
                                       HorizontalAlignment="Stretch"
                                       VerticalAlignment="Stretch"
                                       Fill="White">
                            </Rectangle>

                            <TextBlock Text="Location"
                                       Grid.Column="0"
                                       Grid.Row="9"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Grid.Column="2"
                                       Grid.Row="9"
                                       HorizontalAlignment="Center">
	                    <TextBlock.Text>
	                        <MultiBinding StringFormat="{}({0:f},{1:f})">
	                            <Binding ElementName="secondaryStructureEditor" Path="ViewportTopLeft.X"></Binding>
	                            <Binding ElementName="secondaryStructureEditor" Path="ViewportTopLeft.Y"></Binding>
	                        </MultiBinding>
	                    </TextBlock.Text>
                            </TextBlock>

                            <TextBlock Text="Size"
                                       Grid.Column="0"
                                       Grid.Row="10"
                                       HorizontalAlignment="Left"></TextBlock>
                            <TextBlock Grid.Column="2"
                                       Grid.Row="10"
                                       HorizontalAlignment="Center">
	                        <TextBlock.Text>
	                            <MultiBinding StringFormat="{}{0:f} x {1:f}">
	                                <Binding ElementName="secondaryStructureEditor" Path="ViewportSize.Width"></Binding>
	                                <Binding ElementName="secondaryStructureEditor" Path="ViewportSize.Height"></Binding>
	                            </MultiBinding>
	                        </TextBlock.Text>
                            </TextBlock>
                        </Grid>
                        
                        <Expander Header="Structure Model Rendering Properties"
                                  IsExpanded="False">
                            <StackPanel>
                                <Expander Header="Nucleotide Rendering Properties"
                                          IsExpanded="True">
                                    <ContentControl Content="{Binding}"
                                                    ContentTemplate="{StaticResource NucleotideStructureElementRenderingPropertiesEditableTemplate}"
                                                    Foreground="{StaticResource TextBrush}"></ContentControl>
                                </Expander>
                                <Expander Header="Pair Connector Rendering Properties"
                                          IsExpanded="True">
                                    <ContentControl Content="{Binding}"
                                                    ContentTemplate="{StaticResource BasePairConnectorElementRenderingPropertiesEditableTemplate}"
                                                    Foreground="{StaticResource TextBrush}"></ContentControl>
                                </Expander>
                            </StackPanel>
                        </Expander>
                    </StackPanel>
                </Expander>
                
                <Expander Header="Selected Structure Element"
                          IsExpanded="{Binding Path=SelectedElement, Converter={julmar:NullBooleanConverter NonNullTreatment=True, NullTreatment=False}}">
                    <Expander.Resources>
                        <Rendering:StructureElementTemplateSelector x:Key="StructureElementTemplateSelector"
                                                                    NucleotideElementPropertiesTemplate="{StaticResource NucleotideStructureElementPropertiesTemplate}"
                                                                    BasePairElementPropertiesTemplate="{StaticResource BasePairStructureElementPropertiesTemplate}"
                                                                    HelixElementPropertiesTemplate="{StaticResource HelixStructureElementPropertiesTemplate}"
                                                                    LoopElementPropertiesTemplate="{StaticResource LoopStructureElementPropertiesTemplate}"
                                                                    RangeElementPropertiesTemplate="{StaticResource RangeStructureElementPropertiesTemplate}"></Rendering:StructureElementTemplateSelector>
                    </Expander.Resources>
                    <ContentControl Content="{Binding Path=SelectedElement}"
                                    ContentTemplateSelector="{StaticResource StructureElementTemplateSelector}"
                                    Foreground="{StaticResource TextBrush}">
                    </ContentControl>
                </Expander>
            </StackPanel>
        </ScrollViewer> 
    </Grid>
</UserControl>
